<template>
    <div class="solvelist">
        <el-row class="head">
            <el-col >——新增故障类别/故障类别</el-col>
        </el-row>
        <el-row class="title">
            <el-col>故障类别解决列表</el-col>
        </el-row>
        <el-table
                :data="form"
                border
                style="width: 100%">
            <el-table-column
                    prop="description"
                    label="解决方式"
                    style="width: 80%">
            </el-table-column>
            <el-table-column
                    label="操作"
                    style="width: 20%">
                <template slot-scope="scope">
                <el-button
                        size="mini"
                        @click="Solve(scope.$index, scope.row)">修改</el-button>
                </template>
            </el-table-column>
        </el-table>


    </div>
</template>

<script>
    export default {
        name: "solvelist",
        data() {
            return {
               form:[],
                data:{
                    id:'',
                    description:'',
                }
            };
        },
        created() {
            this.data.id=this.$route.params.id;
            this.$axios.post("/api/v1/admin/description/listadmin",this.data).then(result => {
                return result.data
            })
                .then(data =>{
                    this.form=data.data;
                });
        },
        methods:{
            Solve(index, data) {
                this.$prompt('请输入解决方式', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    inputPattern:  /\S{1,}/,
                    inputErrorMessage: '解决方式不为空',
                    inputValue:data.description,
                }).then(({ value }) => {
                    this.$axios.post("/api/v1/admin/description/updateadmin",{"description":value,"id":data.id}).then(result => {
                        return result.data
                    })
                        .then(data =>{
                            this.$message({
                                type: 'success',
                                message: '修改成功'
                            });
                            this.$axios.post("/api/v1/admin/description/listadmin",this.data).then(result => {
                                return result.data
                            })
                                .then(data =>{
                                    this.form=data.data;
                                });
                        });

                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '取消输入'
                    });
                });
            }
        }


    }
</script>

<style scoped>
    .el-input{
        width: 600px;
    }
</style>